import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Home from '@/pages/Home'
import Category from '@/pages/Category.vue'
import Shopcart from '@/pages/Shopcart'
import My from '@/pages/My'
import more from '@/pages/more'
Vue.use(Router)

var router= new Router({
  linkActiveClass:'mui-active',
  routes: [
    {
      path: '/',
      redirect:'/home',
    },
    {
      path:'/home',
      component:Home,
      name:'home',
      meta:{title:'首页'}
    },
    {
      path:'/shopcart',
      component:Category,
      name:'shopcart',
      meta:{title:'购物车'}
    },
    {
      path:'/category',
      component:Shopcart,
      name:'category',
      meta:{title:'订单列表'}
    },
    {
      path:'/my',
      component:My,
      name:'my',
      meta:{title:'我的'}
    },
    {
      path:'/more',
      component:more,
      name:'more',
      meta:{title:'更多'}
    },
    {
      path:'/*',
     redirect:'/home',
    }
  ]
})
  router.beforeEach((to,from,next)=>{
    if(to.meta.title){
      document.title=to.meta.title;
    }
    next();
  })
export default router
